package com.example.tiptravel.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.tiptravel.R;
import com.example.tiptravel.commom.utils.ImageLoader;
import com.example.tiptravel.entity.home.ScenicsBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 45820 on 2016/11/12.
 */

public class MapAdapter extends RecyclerView.Adapter<MapAdapter.MapViewHolder> {


    private List<ScenicsBean> data;
    private Context context;

    public MapAdapter(List<ScenicsBean> data, Context context) {
        this.data = data;
        this.context = context;
    }

    @Override
    public MapViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new MapViewHolder(LayoutInflater.from(context).inflate(R.layout.item_map_vp, parent, false));
    }

    @Override
    public void onBindViewHolder(MapViewHolder holder, int position) {
        holder.tvMapName.setText(data.get(position).getScenicName());
        holder.tvMapDistance.setText("距你"+data.get(position).getDistance()+"km");
        holder.tvMapBreif.setText(data.get(position).getBrief());
        ImageLoader.getInstance().displayImage(data.get(position).getPic(),context,holder.ivMapImg,R.mipmap.icon_bar_post,R.mipmap.icon_bar_post);
    }

    @Override
    public int getItemCount() {
        return data != null ? data.size() : 0;
    }

    public class MapViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.tv_map_name)
        TextView tvMapName;
        @BindView(R.id.tv_map_distance)
        TextView tvMapDistance;
        @BindView(R.id.iv_map_img)
        ImageView ivMapImg;
        @BindView(R.id.tv_map_breif)
        TextView tvMapBreif;

        public MapViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this,itemView);
        }
    }
}
